<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl.linkpage.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/common.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/My97DatePicker/WdatePicker.js"></script>

<div class="tongrong-box" style="width:680px;">
	<form class="login-box-form J-ajaxForm" action="<?php echo $this->id > 0 ? '/role/packupdate/option/packsave/' : '/role/packsave/option/packsave/';?>" method="post" autocomplete="off">
	<div class="tongrong-box-main">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0">
        	<tr>
            	<td width="90px" height="30">编　　号：</td>
                <td>
                	<input name="p_code" type="text" id="p_code" size="35" value="<?php echo $this->data['p_code'];?>" />
                </td>
            </tr>
            <tr>
            	<td height="30">权限包名称：</td>
                <td>
                	<input name="p_name" type="text" id="p_name" size="35" value="<?php echo $this->data['p_name'];?>" />
                </td>
            </tr>
            <tr>
            	<td>添加权限：</td>
                <td style="padding:10px 0;">
                	<style type="text/css">
                    	.role-box-right {
							width:451px;
							height:200px;
							overflow-y:scroll;
							overflow-x:hidden;
							box-sizing:border-box;
							-webkit-box-sizing:border-box;
							-moz-box-sizing:border-box;
							border:1px solid #e1e1e1
						}
						.role-box-right dt,.role-box-right dd {
							line-height:22px;
						}
						.role-box input[type="radio"] {
							vertical-align:sub;
						}
						.role-box-right>dl>dd {
							padding-left:18px;
						}
						.role-box-right input[type="checkbox"] {
							vertical-align:sub;
							margin-right:5px;
						}
						
						.role-box-right>dl>dd>dl>dd {
							padding-left:38px;
						}
                    </style>
                    
                	<div class="role-box-right J-role-box-h" style="max-height:200px;">
                        <?php
							if(!empty($this->purview[0]['next'])) foreach($this->purview[0]['next'] as $ok => $ov){
						?>
						<dl>
							<dt><em class="ico-arrows-on on J-ico-arrows"></em>&nbsp;<em class="ico-folder-open"></em>&nbsp;<input type="checkbox" name="p_role[]" value="<?php echo $ov['id'];?>"<?php echo !empty($this->data['p_role']) && in_array($ov['id'], $this->data['p_role']) ? ' checked="checked"' : '';?> /><?php echo $ov['name'];?></dt>
							<dd>
								<?php
									if(!empty($ov['next'])) foreach($ov['next'] as $sk => $sv){
								?>
								<dl>
									<dt>
                                    	<?php
											if(empty($sv['next'])){
										?>
											<em class="ico-leaf"></em>&nbsp;
										<?php
											}else{
										?>
											<em class="ico-arrows-on on J-ico-arrows"></em>&nbsp;<em class="ico-folder-open"></em>&nbsp;
										<?php
											}
										?>
                                    	<input type="checkbox" name="p_role[]" value="<?php echo $sv['id'];?>" <?php echo !empty($this->data['p_role']) && in_array($sv['id'], $this->data['p_role']) ? ' checked="checked"' : '';?> /><?php echo $sv['name'];?>
                                    </dt>
                                    
                                    
									<dd>
										<dl>
											<?php
												if(!empty($sv['next'])) foreach($sv['next'] as $tk => $tv){
											?>
											<dd><em class="ico-leaf"></em>&nbsp;<input type="checkbox" name="p_role[]" value="<?php echo $tv['id'];?>"<?php echo !empty($this->data['p_role']) && in_array($tv['id'], $this->data['p_role']) ? ' checked="checked"' : '';?> /><?php echo $tv['name'];?></dd>
											<?php
												}
											?>
										</dl>
									</dd>
								</dl>
								<?php
									}
								?>
							</dd>
						</dl>
						<?php
							}
						?>
                    </div>
                </td>
            </tr>
            <tr>
            	<td height="30">备注说明：</td>
                <td id="areas">
                	<textarea name="p_text" id="p_text" style="width: 451px; height: 95px;"><?php echo $this->data['p_text'];?></textarea>
                </td>
            </tr>
            
        </table>
    </div>
    <div class="luru-box-btn mt20" style="margin-right:75px;">
		<input type="hidden" name="option" value="save" />
		<input type="hidden" name="id" value="<?php echo $this->id;?>" />
    	<input class="btn-submit-blue fn-left mr15 J-submit" type="submit" value="提交" />
        <a class="a-btn-close J-a-btn-close" href="javascript:;">关闭</a>
    </div>
	</form>
</div>
<script>
	//关闭弹出
	$(".J-a-btn-close").on('click',function(){
		var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
		parent.Ext.getCmp(winElement.id).close();
	});
	
	$(document).ready(function(e) {
		//全选
        $(".J-submit").on('click',function(){
			$(this).dyhlForm({
				beforefunction:submitChk,
				nofunction:function(){
					$(".J-submit").prop('disabled',false);
				},
				sucessfunction:function(data){
					$(".J-submit").prop('disabled',false);
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							window.parent.location.reload();	
						});
						
					}else{
						Ext.Msg.alert('提示',data['msg']);
					}
				}	
			});	
		});
		
		//菜单展开、关闭
		$(".J-role-box-h").on('click','.J-ico-arrows',function(){
			if($(this).hasClass('on')){
				$(this).addClass("ico-arrows").removeClass("ico-arrows-on");
				$(this).closest('dt').siblings('dd').addClass('fn-hide');
				$(this).removeClass('on');	
			}else{
				$(this).addClass("ico-arrows-on").removeClass("ico-arrows");
				$(this).closest('dt').siblings('dd').removeClass('fn-hide');
				$(this).addClass('on');	
			}	
		});
		
		//菜单全选、取消
		$(".J-role-box-h").on('change','input[type="checkbox"]',function(){
			$(this).closest('dt').siblings('dd').find('input[type="checkbox"]').prop('checked',$(this).prop("checked"));	
		});
    });
	
	//表单验证
	function submitChk(){
		if($("#p_code").val() == ''){
			Ext.Msg.alert('提示','编号不能为空!');	
			return false;
		}
		
		if($("#p_name").val() == ''){
			Ext.Msg.alert('提示','权限包名称不能为空!');	
			return false;
		}
		
		$(".J-submit").prop('disabled',true);
			
	}
	
</script>

<?php include $this->Render('footer.php'); ?>